package com.blb.zy_community.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.blb.zy_community.entity.ResponseResult;
import com.blb.zy_community.entity.ZyComplaintSuggest;
import com.blb.zy_community.service.impl.ZyComplaintSuggestServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

/**
 * <p>
 * 投诉建议  前端控制器
 * </p>
 *
 * @author 二组
 * @since 2023-06-18
 */
@CrossOrigin
@RestController

public class ZyComplaintSuggestController {
    @Autowired
    private ZyComplaintSuggestServiceImpl zyComplaintSuggestService;
    @GetMapping("suggest-page")
    public ResponseResult<Page<ZyComplaintSuggest>> getSuggest(@RequestParam(required = false,defaultValue = "1") Long current,
                                                               @RequestParam(required = false,defaultValue = "5") Long size,
                                                               @RequestParam(required = false,defaultValue = "") String complaintSuggestType){
        Page<ZyComplaintSuggest> suggest = zyComplaintSuggestService.findSuggest(current, size, complaintSuggestType);
        return ResponseResult.ok(suggest);
    }

    @PutMapping("/suggest")
    public ResponseResult<String> updateStatus(@RequestBody ZyComplaintSuggest zyComplaintSuggest){
        zyComplaintSuggestService.updateById(zyComplaintSuggest);
        return ResponseResult.ok(zyComplaintSuggest);
    }



}
